package cn.wetcland.urban.admin.service.impl;

import cn.wetcland.urban.admin.mapper.UtAppealMapper;
import cn.wetcland.urban.admin.service.UtAppealService;
import cn.wetcland.urban.common.MyAssert;
import cn.wetcland.urban.generator.domain.UtAppeal;
import cn.wetcland.urban.generator.dto.BaseConditionSearchDTO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
* @author Wetcland
* @description 针对表【ut_appeal】的数据库操作Service实现
* @createDate 2024-01-21 09:51:59
*/
@Service
public class UtAppealServiceImpl extends ServiceImpl<UtAppealMapper, UtAppeal> implements UtAppealService {

    @Resource
    private UtAppealMapper appealMapper;

    @Override
    public Page<UtAppeal> appealList(BaseConditionSearchDTO searchDTO) {
        Page<UtAppeal> utAppealPage = new Page<>(searchDTO.getCurPage(), searchDTO.getPageSize());
        return appealMapper.selectAppealPageList(utAppealPage, searchDTO);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void appealDelete(Long appealId) {
        appealMapper.deleteById(appealId);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void appealResolve(Long appealId, String appealResponse) {
        UtAppeal utAppeal = appealMapper.selectById(appealId);
        MyAssert.notNull(utAppeal, "该申诉记录不存在");
        utAppeal.setAppealResponse(appealResponse);
        utAppeal.setAppealStatus(1);
        appealMapper.updateById(utAppeal);
    }
}




